//
//  OECardTableViewCell.m
//  OneEightyNine
//
//  Created by Mac on 2019/3/7.
//  Copyright © 2019 stoneobs. All rights reserved.
//

#import "OECardTableViewCell.h"

@interface  OECardTableViewCell()
@property(nonatomic, strong) UIImageView                     *backgroundImageView;/**<  */
@property(nonatomic, strong) UIImageView                     *iconImageView;/**<  */
@property(nonatomic, strong) STLabel                     *nameLable;/**<  */
@property(nonatomic, strong) STLabel                     *banknameLable;/**<  */
@property(nonatomic, strong) STLabel                     *cardLable;/**<  */
@end
@implementation OECardTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 140;
}
#pragma mark --subView
- (void)configSubView{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = UIColor.clearColor;
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 0, UIScreenWidth-40, 130)];
    imageView.image = [UIImage imageNamed:@""];
    imageView.clipsToBounds = YES;
    imageView.layer.cornerRadius = 8;
    [self addSubview:imageView];
    self.backgroundImageView = imageView;
    
    
    UIImageView * iconimageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 60, 60)];
    iconimageView.image = [UIImage imageNamed:@""];
    iconimageView.clipsToBounds = YES;
    iconimageView.layer.cornerRadius = 30;
    [self.backgroundImageView addSubview:iconimageView];
    self.iconImageView = iconimageView;
    
    CGFloat maxWitdh = UIScreenWidth - iconimageView.right - 20;
    self.nameLable = [[STLabel alloc] initWithFrame:CGRectMake(iconimageView.right + 10, iconimageView.top, maxWitdh, 44)
                                                     text:@""
                                                textColor:UIColor.whiteColor
                                                     font:16
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [self.backgroundImageView addSubview:self.nameLable];
    
    
    self.banknameLable = [[STLabel alloc] initWithFrame:CGRectMake(iconimageView.right + 10, iconimageView.top, maxWitdh, 25)
                                               text:@""
                                          textColor:UIColor.whiteColor
                                               font:14
                                        isSizetoFit:NO
                                      textAlignment:NSTextAlignmentLeft];
    [self.backgroundImageView addSubview:self.banknameLable];
    self.banknameLable.centerY = self.iconImageView.bottom;
    
    self.cardLable = [[STLabel alloc] initWithFrame:CGRectMake(iconimageView.right + 10, self.banknameLable.bottom, maxWitdh, 25)
                                                   text:@""
                                              textColor:UIColor.whiteColor
                                                   font:14
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentLeft];
    [self.backgroundImageView addSubview:self.cardLable];
}
- (void)setModel:(OECardModel *)model{
    _model = model;
    self.nameLable.text = model.true_name;
    self.banknameLable.text = model.bank_name;
    self.cardLable.text = model.account;
    if (model.account_type.integerValue == 6) {
        self.iconImageView.image = [UIImage imageNamed:@"104×10建行银行logo"];
        self.backgroundImageView.image = [UIImage imageNamed:@"702×264建行背景"];
    }
    if (model.account_type.integerValue == 1) {
        self.iconImageView.image = [UIImage imageNamed:@"104×104工商银行logo"];
        self.backgroundImageView.image = [UIImage imageNamed:@"702×264工商背景"];
    }
    if (model.account_type.integerValue == 3) {
        self.iconImageView.image = [UIImage imageNamed:@"104×104邮政银行logo"];
        self.backgroundImageView.image = [UIImage imageNamed:@"702×264邮政"];
    }
}
@end
